<template>
    <!-- 个人账户页 -->
    <div class="account">
        <div class="header">
            <div class="header_left">您好，尊敬的{{account.nickname}}</div>
            <div class="header_right">
                <img class="switch" src="./../../images/switch.png">
                <router-link to="/login" >切换账号</router-link>
            </div>
        </div>
        <div class="bg_account" :style="{'height':height}">
            <mt-swipe :auto="0" @change="handleChange">
                <mt-swipe-item v-for="(slider,index) in sliders" :key="index">
                    <div class="relative">
                        <div class="absolute account_info">
                            <div class="account_info_head">
                                <p class="account_info_title" v-if="index==0">当前魅力值：</p>
                                <p class="account_info_title"  v-if="index==1">当前余额：</p>
                                <p><router-link :to="index==0?'/recordlist':'/balancelist'" style="color:#fff;">提现记录</router-link><img class="go_record" src="./../../images/go_record.png"></p>
                            </div>
                            <div class="charm_info">
                                <p class="charm_info_value" v-if="index==0">{{slider.charm | format}}</p>
                                <p class="charm_info_value" v-if="index==1">{{slider.money | format}}</p>
                                <router-link :to="'/bind?type='+slider.account" class="bind_btn">{{slider.account == 0?'绑定':'修改'}}支付宝</router-link>
                            </div>
                            <div class="date_info">
                                <div>
                                    <p class="date_title">最近30天收入：</p>
                                    <p class="date_number">{{slider.three_total | format}}</p>
                                </div>
                                <div>
                                    <p class="date_title">最近7天收入：</p>
                                    <p class="date_number">{{slider.seven_total | format}}</p>
                                </div>
                                <div>
                                    <p class="date_title">今日收入：</p>
                                    <p class="date_number">{{slider.current_total | format}}</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </mt-swipe-item>
            </mt-swipe>
            <div class="bottom_btn">
                <router-link :to="`/forward?type=1&current=${current}`" class="btn_return">转为钻石</router-link>
                <div class="btn_grey" @click="judgeBind">提现</div>
            </div>
        </div>
    </div>
</template>
<script>
    export default{
        data:function(){
            return{
                money:'',
                account:{},
                sliders:[],
                height:0,
                current:0
            }
        },
        mounted(){
            this.getUserCharm(1);
            this.getUserCharm(2);
            this.height = ($(window).height()-$(".header").height())+'px';
        },
        methods:{
            getUserCharm(type){
                this.get({
                    url:'/api/user/charminfo?type='+type
                }).then(res=>{
                    this.account = res;
                    this.sliders.push(res);
                })
            },
            handleChange(index) {
                this.current = index;
            },
            judgeBind(){
                if(this.account.account == 1){
                    this.getCheckStatus();
                }else{
                    this.confirm("请绑定支付宝后再进行提现操作！");
                    setTimeout(()=>{
                        this.$router.push('/bind?type=0');
                    },2000);
                    
                }
            },
            //判断资料审核状态
            getCheckStatus(){
                this.get({
                    url:"api/user/withdrawaldata?currency=charm"
                }).then(res=>{
                    //资料通过才进入提现页面
                    if(res.audit == 2){
                        this.$router.push('/forward?type=2&current='+this.current);
                    }else if(res.audit == 1){
                        this.confirm("您的资质正在审核中，请耐心等待哦~");
                    }else{
                        this.$router.push("/checkidentity");
                    }
                })
            },
        }
    }
</script>
<style type="text/css">
    @import url('./account.css');
</style>
